/**
 * Collection List
 *  -  relation_useractivities
 */

var Schema = mongoose.Schema;

//===========================用户活动关系表==============================
var userActivityMongoSchema = new Schema({
    user: {type: Schema.Types.ObjectId, ref: 'user'},
    activity: {type: Schema.Types.ObjectId, ref: 'activity'},
    contactName: String,
    phone: String
});
mongoose.model('Relation_userAcitvity', userActivityMongoSchema, 'relation_useractivities');

//===========================邀请码device 绑定表
var deviceCodeBindSchema = new Schema({
    user: {type: Schema.Types.ObjectId, ref: 'user'},
    deviceId: String,
    invitationCode: String,
    status: {type: Boolean, default: false},
    dateCreated: {type: Date, default: Date.now}
});
mongoose.model('relation_deviceCodeBind', deviceCodeBindSchema, 'relation_deviceCodeBind');

//==========================邀请记录================
var userInvitationSchema = new Schema({
    invitee: {type: Schema.Types.ObjectId, ref: 'user'},                //被邀请人
    inviter: {type: Schema.Types.ObjectId, ref: 'user', index: true},   //邀请人
    score: {type: Number, default: 0},                                                      //情值奖励数值
    type: Number,                                               //奖励类型 1,情值;2,代金券
    dateCreated: {type: Date, default: Date.now},
    dateLastModified: {type: Date, default: Date.now}
});
mongoose.model('user_invitation', userInvitationSchema, 'user_invitation');

var userInvitationShareSchema = new Schema({
    inviter: {type: Schema.Types.ObjectId, ref: 'user'},   //邀请人
    invitationCode: String,
    phone: {type: String, unique: true},
    groupId: String,
    type: Number,                                       //1,邀请有礼分享  2,家庭群组  3,短信邀请
    os: String,
    dateCreated: {type: Date, default: Date.now}
});
mongoose.model('user_invitation_share', userInvitationShareSchema, 'user_invitation_share');

